Skip to content

feat: add brownie android#257

Merged
hurali97 merged 28 commits intomainfrom
feat/brownie-android
Mar 31, 2026
Merged

feat: add brownie android#257
hurali97 merged 28 commits intomainfrom
feat/brownie-android

Conversation

@hurali97
Copy link
Copy Markdown
Member

@hurali97 hurali97 commented Feb 25, 2026

Summary

This adds support for android to the brownie package. The usage is as simple as after creating the brownfieldstore.brownie.ts:

  • Register the Store:
registerStoreIfNeeded(
  storeName = BrownfieldStore.STORE_NAME
) {
  BrownfieldStore(
    counter = 0.0,
    user = User(name = "Username")
  )
}
  • Declare the Store:
val store: Store<BrownfieldStore>? = StoreManager.shared.store(BrownfieldStore.STORE_NAME)
  • Use the Store:
// Read current state
val current = store?.state

// Update whole state with copy()
store?.set { state ->
  state.copy(counter = state.counter + 1)
}

// Subscribe to full state changes
val unsubscribe = store?.subscribe { newState ->
  println("Counter: ${newState.counter}")
}

// Cleanup subscription
unsubscribe?.invoke()

Test plan

  • CI Passes - 🟢
  • Tested Locally - 🟢
Screen.Recording.2026-02-26.at.5.18.47.PM.mov

@hurali97 hurali97 changed the title Feat/brownie android feat: add brownie android Feb 27, 2026
Comment on lines +2 to +3
'@callstack/brownie': minor
'@callstack/brownfield-cli': minor
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we go with a major release instead? However, then it will not align with react-native-brownfield version as that would still be v3

Copy link
Copy Markdown
Member

@thymikee thymikee Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do it in a point release, no need for major (it’s a new thing). Should align

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped all minors to align.

@hurali97 hurali97 marked this pull request as ready for review February 27, 2026 08:04
Copilot AI review requested due to automatic review settings February 27, 2026 08:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Android support to the @callstack/brownie package by introducing an Android runtime (Kotlin facade + JNI bridge) and updating CLI/docs/examples so stores can be used from Kotlin as well as Swift/JS.

Changes:

  • Enable Kotlin codegen (and default to Swift + Kotlin generation) in the CLI.
  • Add packages/brownie/android implementation: Kotlin Store/StoreManager, JNI bridge, and RN TurboModule package/module.
  • Update docs and example apps to show Android usage and wire up counters.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/cli/src/brownie/commands/codegen.ts Default codegen now targets Swift + Kotlin.
packages/brownie/react-native.config.js Removes Android-disable config to allow autolinking.
packages/brownie/package.json Publishes Android sources in npm package and excludes Android build artifacts.
packages/brownie/cpp/BrownieStore.cpp Calls change callback outside mutex to reduce lock contention.
packages/brownie/android/src/main/java/com/callstack/brownie/StoreManager.kt Adds process-wide store registry for Kotlin stores.
packages/brownie/android/src/main/java/com/callstack/brownie/Store.kt Adds Kotlin typed store wrapper syncing with native snapshot + subscriptions.
packages/brownie/android/src/main/java/com/callstack/brownie/BrownieStoreRegistration.kt Adds registration helpers including “register once” convenience API.
packages/brownie/android/src/main/java/com/callstack/brownie/BrownieStoreDefinition.kt Adds serializer/definition APIs with Gson default implementation.
packages/brownie/android/src/main/java/com/callstack/brownie/BrownieStoreBridge.kt Adds Kotlin/JNI bridge to C++ runtime and change listener fanout.
packages/brownie/android/src/main/java/com/callstack/brownie/BrowniePackage.kt Registers Android TurboModule package.
packages/brownie/android/src/main/java/com/callstack/brownie/BrownieModule.kt Android TurboModule: installs JSI + forwards store-change events to JS.
packages/brownie/android/src/main/cpp/JNIBrownieStoreBridge.cpp JNI glue for store operations + store-change emission into Kotlin.
packages/brownie/android/src/main/cpp/CMakeLists.txt Builds Android libbrownie.so and links ReactAndroid/fbjni/folly.
packages/brownie/android/src/main/AndroidManifest.xml Declares Android package manifest for the library.
packages/brownie/android/build.gradle Android library Gradle config (SDKs, CMake, dependencies).
packages/brownie/.gitignore Ignores Android build output for the package.
docs/docs/docs/api-reference/brownie/swift-usage.mdx Updates Swift page to link to separate Android docs.
docs/docs/docs/api-reference/brownie/overview.mdx Marks Android as supported and links Android usage docs.
docs/docs/docs/api-reference/brownie/getting-started.mdx Adds Android setup + packaging/publishing steps.
docs/docs/docs/api-reference/brownie/android-usage.mdx New Android API guide (easy + advanced serialization paths).
docs/docs/docs/api-reference/brownie/_meta.json Adds Android usage page to docs nav.
apps/RNApp/src/components/counter/index.tsx Switches to shared counter using useStore and an increment button.
apps/RNApp/src/components/counter/index.ios.tsx Removes iOS-specific counter component (now shared).
apps/RNApp/package.json Adds Brownie Kotlin codegen config.
apps/ExpoApp/package.json Adds Brownie Kotlin codegen config.
apps/ExpoApp/components/counter/index.tsx Switches to shared counter using useStore and an increment button.
apps/ExpoApp/components/counter/index.ios.tsx Removes iOS-specific counter component (now shared).
apps/AndroidApp/app/src/vanilla/java/com/callstack/brownfield/android/example/BrownfieldStore.kt Adds typealiases to generated store types for the vanilla flavor.
apps/AndroidApp/app/src/main/java/com/callstack/brownfield/android/example/components/GreetingCard.kt Wires Compose UI to Brownie store updates and increment action.
apps/AndroidApp/app/src/main/java/com/callstack/brownfield/android/example/MainActivity.kt Registers store once during app startup.
apps/AndroidApp/app/src/expo/java/com/callstack/brownfield/android/example/BrownfieldStore.kt Adds typealiases to generated store types for the expo flavor.
apps/AndroidApp/app/build.gradle.kts Bumps JVM target to 17 and adds Gson dependency.
.changeset/red-llamas-love.md Publishes minor bumps for impacted packages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hurali97 hurali97 requested a review from artus9033 February 27, 2026 12:57
Copy link
Copy Markdown
Collaborator

@artus9033 artus9033 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We can address full reuse of the C++ code in CXX modules in the future, as discussed

@hurali97 hurali97 force-pushed the feat/brownie-android branch from 1e1e755 to ee7580a Compare March 14, 2026 18:10
@hurali97 hurali97 force-pushed the feat/brownie-android branch from ee7580a to 51c55bd Compare March 30, 2026 07:52
@hurali97 hurali97 merged commit d0e6203 into main Mar 31, 2026
14 checks passed
@hurali97 hurali97 deleted the feat/brownie-android branch March 31, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants